package com.tnovoselec.android.travelassistant.activity;

import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.provider.Settings;

import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.tnovoselec.android.travelassistant.R;

public class SettingsActivity extends SherlockPreferenceActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
		super.onCreate(savedInstanceState);

		addPreferencesFromResource(R.xml.settings);
		findPreference(getString(R.string.gps_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {

			@Override
			public boolean onPreferenceClick(Preference preference) {
				Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
				startActivity(i);
				return true;
			}
		});
		findPreference(getString(R.string.gas_prices_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {

			@Override
			public boolean onPreferenceClick(Preference preference) {
				Intent i = new Intent(SettingsActivity.this, GasPricesActivity.class);
				startActivity(i);
				return true;
			}
		});
		findPreference(getString(R.string.exchange_rates_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {

			@Override
			public boolean onPreferenceClick(Preference preference) {
				Intent i = new Intent(SettingsActivity.this, ExchangeRatesActivity.class);
				startActivity(i);
				return true;
			}
		});

	}

	@Override
	protected void onPause() {
		overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
		super.onPause();
	}
}
